package zl.com;

import java.util.ArrayList;
/**
 * Created with Intellij IDEA.
 * Description:
 * User:张蕾
 * Date:2023-05-30
 * Time:23:15
 */
public class Manager extends User{
    public Manager() {
    }

    public Manager(String name, int money) {
        super(name, money);
    }

     public ArrayList<Integer> Send(int totalMoney,int count){
        ArrayList<Integer> redList = new ArrayList<>();//一个集合定义红包

        int leftMoney = super.getMoney();//群主当前余额
        if (totalMoney > leftMoney){//判断一下余额多少
            System.out.println("余额不足");
            return redList;//返回空集合
        }
        //扣钱，重新设置余额
        super.setMoney(leftMoney - totalMoney);

        //发红包平均拆成count份
         int avg = totalMoney/count;
         int mod = totalMoney%count;
         //除不开的零头，放在一个集合中
         for (int i = 0; i < count - 1; i++) {
             redList.add(avg);
         }
         //最后一个红包
         int last = avg + mod;
         redList.add(last);

         return redList;
     }
}
